import vue from 'vue'
import Vuex from 'vuex'
vue.use(Vuex)
import persistedState from 'vuex-persistedstate'
import index1 from './index'

// 用户信息
import user from '../js/user.vue'
// import one from './one'
// import index1 from './index1'         
export default new Vuex.Store({
    //state  相当于data，用来存储数据源
    // 用户数据
    state: {
        // 商品页面的数据源
        newtableData: [
            {
                name: "小米13",
                price: "3999",
                operate: '200000',
            },
            {
                name: "IQOO Neo7",
                price: "2799",
                operate: '200000'
            },
            {
                name: "OPPO K10 Pro",
                price: "2399",
                operate: '200000'
            },
            {
                name: "Iphone14",
                price: "8999",
                operate: '200000'
            },
            {
                name: "IQOO Neo7",
                price: "2799",
                operate: '200000'
            },
            {
                name: "OPPO K10 Pro",
                price: "2399",
                operate: '200000'
            },
            {
                name: "Iphone14",
                price: "8999",
                operate: '200000'
            },
            {
                name: "IQOO Neo7",
                price: "2799",
                operate: '200000'
            },
            {
                name: "OPPO K10 Pro",
                price: "2399",
                operate: '200000'
            },
            {
                name: "Iphone14",
                price: "8999",
                operate: '200000'
            },
            {
                name: "IQOO Neo7",
                price: "2799",
                operate: '200000'
            },
            {
                name: "OPPO K10 Pro",
                price: "2399",
                operate: '200000'
            },
            {
                name: "Iphone14",
                price: "8999",
                operate: '200000'
            },
        ],
        tableData: [{
            date: "2016-05-03",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        },
        {
            date: "2016-05-02",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        },
        {
            date: "2016-05-04",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        },
        {
            date: "2016-05-01",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        },
        {
            date: "2016-05-08",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        },
        {
            date: "2016-05-06",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        },
        {
            date: "2016-05-07",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        },
        {
            date: "2016-05-01",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        },
        {
            date: "2016-05-08",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        },
        {
            date: "2016-05-06",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        },
        {
            date: "2016-05-07",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        }, {
            date: "2016-05-01",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        },
        {
            date: "2016-05-08",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        },
        {
            date: "2016-05-06",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        },
        {
            date: "2016-05-07",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        }, {
            date: "2016-05-01",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        },
        {
            date: "2016-05-08",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        },
        {
            date: "2016-05-06",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        },
        {
            date: "2016-05-07",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        }, {
            date: "2016-05-01",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        },
        {
            date: "2016-05-08",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        },
        {
            date: "2016-05-06",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        },
        {
            date: "2016-05-07",
            name: "王小虎",
            gender: '男',
            age: 24,
            address: "上海市普陀区金沙江路 1518 弄",
        }
        ],
        // 管理员信息
        rootisinformation: {
            rootimg: require("../assets/touxiang.jpg"),
            name: "疯狂的红兔子",
            password: 123456,
            rootlo: '超级管理员',
            roottime: '12:00',
            rootadders: '成都'
        },
        //手机出货量,当日,当月 总计
        mobilePhoneShipmentVolume: [{
            name: 'oppo',
            day: 121,
            month: 1536,
            total: 35634
        }, {
            name: 'vivo',
            day: 131,
            month: 4352,
            total: 34953
        }, {
            name: '小米',
            day: 143,
            month: 4303,
            total: 68956
        }, {
            name: '华为',
            day: 123,
            month: 2324,
            total: 39867
        }, {
            name: 'iphone',
            day: 112,
            month: 2334,
            total: 46853
        }, {
            name: '魅族',
            day: 123,
            month: 2312,
            total: 32814
        },],
        //手机厂商
        mobilePhoneManufacturer: ['小米', 'oppo', '华为', 'vivo', 'iphone', '三星'],
        //折线图数据  
        mylineChart_data: {
            mi: [723, 236, 234, 634, 652, 567, 745],
            huawei: [322, 323, 522, 432, 562, 532, 132],
            vivo: [523, 345, 123, 421, 233, 112, 345],
            oppo: [231, 344, 512, 321, 123, 432, 99],
            iphone: [156, 321, 356, 324, 633, 421, 955],
            sansong: [123, 200, 57, 99, 109, 100, 76]
        },
        //最近七天
        lastSevenDays: ['3-1', '3-2', '3-3', '3-4', '3-5', '3-6', '3-7'],
        //饼图数据
        salesProportionInThePastMonth: [
            { value: 335, name: '小米' },
            { value: 310, name: 'oppo' },
            { value: 234, name: '华为' },
            { value: 135, name: 'vivo' },
            { value: 548, name: 'iphone' },
            { value: 158, name: '三星' },
        ],
        newsum: 0
    },
    //getters  相当于 computed 计算属性
    getters: {
        //所依赖的数据源发生变化时firstName也会发生变化
    },
    //mutations  可以直接修改state里面的数据源
    mutations: {
        // 删除用户数据
        delet(state, val) {
            state.tableData.splice(val, 1)
        },
        jiauser(state, val) {
            state.tableData.unshift(val)
        },
        changeTime(state, val) {
            vue.set(state.rootisinformation, 'roottime', val)
        },
        //下架
        cahnge_ShopData(state, val) {
            state.newtableData.splice(val, 1)
        }


    },
    //actions  一般用于异步修改state的据
    // actions: {
    //     addNum(comtext, val) {
    // comtext.commit("mutation-name",payload);
    //     }
    // },
    //modules  模块化vuex (可以引入多个store.js)
    modules: {
        // indexname: index1,
        // one1: one
        index1
    },
    plugins: [persistedState()] //数据持久化
})